package org.yuanqiframework.yuanqi.core.utils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.List;

/**
 * @description:
 * @author: 曹波涛
 * @create: 2025/4/10
 **/
public class FilesUtils {

    public static String readText(File file) throws IOException {
        List<String> ls = Files.readAllLines(file.toPath());
        return String.join("\n", ls);
    }

    public static void writeText(File file, String data, StandardOpenOption... options) throws IOException {
        Files.write(file.toPath(), data.getBytes(), options);
    }

    public static void copyFile(File source, File target) throws IOException {
        Files.copy(source.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);

    }


}
